<template>
	<view class="container">
		<navView navTitle="服务评价" titleColor="#fff" :isBack="true"></navView>
		<view class="content">
			<view class="data-statistics">
				<view class="title">
					<view class="tiao"></view>
					总体评分
					<view class="spans">
						(10分)
					</view>
				</view>
				<uni-data-select :clear="false" v-model="formData.overall" :localdata="range"></uni-data-select>
			</view>
			<view class="data-statistics">
				<view class="title">
					<view class="tiao"></view>
					效率评分
					<view class="spans">
						(10分)
					</view>
				</view>
				<uni-data-select :clear="false" v-model="formData.efficiency" :localdata="range"></uni-data-select>
			</view>
			<view class="data-statistics">
				<view class="title">
					<view class="tiao"></view>
					服务人员评分
					<view class="spans">
						(10分)
					</view>
				</view>
				<uni-data-select :clear="false" v-model="formData.people" :localdata="range"></uni-data-select>				
			</view>
			<view class="data-statistics">
				<view class="title">
					<view class="tiao"></view>
					建议
				</view>
				<view class="textarea">
					<textarea name="" placeholder="请输入" v-model="formData.suggestion" cols="30" rows="10" maxlength="50"></textarea>
					<view class="tiao">
						0/50
					</view>
				</view>
			</view>
		</view>
		<button class="btn" @click="handleSubmit">提交</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				formData: {
					contract_id: 0, // 关联id
					overall: 0, // 总体评分
					efficiency: 0, // 效率评分
					people: 0, // 人员评分
					suggestion: "", // 建议					
				},
				range: [{
						value: 0,
						text: "0分"
					},
					{
						value: 1,
						text: "1分"
					},
					{
						value: 2,
						text: "2分"
					},
					{
						value: 3,
						text: "3分"
					},
					{
						value: 4,
						text: "4分"
					},
					{
						value: 5,
						text: "5分"
					},
					{
						value: 6,
						text: "6分"
					},
					{
						value: 7,
						text: "7分"
					},
					{
						value: 8,
						text: "8分"
					},
					{
						value: 9,
						text: "9分"
					},
					{
						value: 10,
						text: "10分"
					}
				],
			}
		},
		onLoad(options){
			this.formData.contract_id = options.contractID
		},
		methods: {
			handleSubmit() {
				console.log('表单数据:', this.formData);
				this.$request('/addons/qingdong/rating/addContract', 'POST', this.formData).then(res => {
					console.log(res)
					if (res.code == 1) {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
						setTimeout(() => {
							uni.navigateBack()
						}, 1200)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 20px;
	}

	.content {
		.data-statistics {
			background-color: #ffffff;
			border-radius: 20rpx;
			box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
			margin-bottom: 20rpx;
			padding: 20rpx;
			box-sizing: border-box;

			.title {
				font-size: 28rpx;
				display: flex;
				align-items: center;

				.tiao {
					width: 6rpx;
					height: 22rpx;
					background: #1B87E8;
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					margin-right: 10rpx;
				}

				.spans {
					margin-left: 30rpx;
					font-weight: 400;
					font-size: 28rpx;
					color: #7D7D7D;
				}
			}

			input {
				font-size: 28rpx;
			}

			.textarea {
				width: 100%;
				height: 204rpx;
				background: #FBFBFB;
				border-radius: 10rpx;
				padding: 20rpx;
				box-sizing: border-box;
				margin-top: 10rpx;
				font-size: 28rpx;
				position: relative;

				textarea {
					width: 100%;
					height: 100%;
					background: #FBFBFB;
					border-radius: 10rpx;
				}

				.tiao {
					position: absolute;
					right: 20rpx;
					bottom: 20rpx;
					color: #7D7D7D;
				}
			}
		}
	}

	::v-deep .uni-select {
		border: none;
	}

	::v-deep .uni-select__input-text {
		text-align: right;
		padding-right: 30rpx;
	}

	.btn {
		position: fixed;
		width: 95%;
		background: #008EFF;
		color: #fff;
		border-radius: 50rpx;
		left: 50%;
		transform: translate(-50%);
		bottom: 50rpx;
	}
</style>